package service

import (
	"fmt"
	"log"
	"net/http"
	_ "net/http/pprof"
)

func HttpStart(ip string, port int) {
	// 注册WebSocket路由
	http.HandleFunc("/chat", handleWebSocket)

	// 获取消息列表
	http.HandleFunc("/message/list", handleMessageList)

	// 启动HTTP服务器
	host := fmt.Sprintf("%s:%d", ip, port)
	log.Printf("HTTP service starting on %v", host)
	if err := http.ListenAndServe(host, nil); err != nil {
		log.Fatal("ListenAndServe error:", err)
	}
}
